﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

using ShootSearch.Util;

namespace ShootSearch.Common
{
    #region PageRule
    /// <summary>
    /// Page regex match rule
    /// </summary>
    [Serializable]
    [TypeConverter(typeof(ExpandableConverter<PageRule>))]
    public class PageRule
    {
        /// <summary>
        /// Gets or sets the rule type
        /// </summary>
        public PageRuleType Type { get; set; }
        /// <summary>
        /// The regex rule
        /// </summary>
        public TreeRule Rule { get; set; }
        /// <summary>
        /// Continued to match the next rule
        /// </summary>
        public bool CanContinue { get; set; }

        /// <summary>
        /// Constructor
        /// </summary>
        public PageRule()
        {
            Rule = new TreeRule();
            CanContinue = false;
        }

        /// <summary>
        /// Get a string summary
        /// </summary>
        /// <returns>the string rule</returns>
        public override string ToString()
        {
            return Rule.ToString();
        }
    } 
    #endregion

    #region PageRuleType
    /// <summary>
    /// Page rule type
    /// </summary>
    public enum PageRuleType
    {
        /// <summary>
        /// Url matched only
        /// </summary>
        UrlOnly,
        /// <summary>
        /// Page source matched only
        /// </summary>
        PageSourceOnly,
        /// <summary>
        /// Either url matched or page source matched
        /// </summary>
        Either,
        /// <summary>
        /// Both url and page matched
        /// </summary>
        Both,
    } 
    #endregion
}
